//package com.city.config;
//
//import com.city.helper.AuthHelper;
//import com.city.helper.BehaviorHelper;
//import com.city.service.report.BehaviorService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//@Component
//public class Interceptor implements HandlerInterceptor {
//
//    @Autowired
//    private AuthHelper authH;
//    @Autowired
//    private BehaviorHelper behaviorH;
//    @Autowired
//    private StringRedisTemplate redis;
//    @Autowired
//    private BehaviorService behaviorS;
//
//    /**
//     * 进入controller层之前拦截请求
//     */
//    @Override
//    public boolean preHandle(HttpServletRequest request,
//                             HttpServletResponse response,
//                             Object handler) throws Exception {
////        String key = authH.getSign();
////        if(key != null && redis.hasKey(key)){
////            String userId = redis.opsForValue().get(key);
////            String uri = request.getRequestURI();
////            System.out.println("请求路由：" + uri);
////            behaviorS.saveBehavior(behaviorH.getBehavior(Integer.parseInt(userId),uri));    //保存请求行为
////            if(!authH.checkAuth(userId,uri)){
////                System.out.println("在访问url为：" + uri + "的路由时，权限不足！");
////                return false;
////            }
////        }else{
////            response.sendRedirect("/for_login");
////            return false;
////        }
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { }
//
//    @Override
//    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { }
//
//}
//
